#include "link.h"
#include <iostream>

Link::Link(Vector3f p, float t, float ph, float l, float global_t, float global_p){
	theta = t;
	phi = ph;
	length = l;
	pos = p;
	global_theta = global_t;
	global_phi = global_p;

	r = (float) rand()/RAND_MAX;
	g = (float) rand()/RAND_MAX;
	b = (float) rand()/RAND_MAX;
}

Vector3f Link::getEnd() {
	Vector3f direction(length*sin(global_theta)*cos(global_phi),
					length*sin(global_theta)*sin(global_phi),
					length*cos(global_theta));
	return pos + direction;
}

Vector3f Link::getMid() {
	return (pos + getEnd())/2;
}
